/**
 * Created by Ji.wenjiang on 2016/9/12.
 */


angular.module('inspinia')
  .controller('doctorChatCtrl', function ($scope, $timeout, $log, values, users, _undefined) {
    init();
    function init() {
      $scope.initDrs = [
        {
          id: '1',
          imageSrc: 'img/a4.jpg',
          timeByNow: '7小时前',
          doctorName: '张小凡',
          occupation: '物理师',
          detailMsg: '邀请你查看患者曹丽华的压模',
          lastTime: '2016-09-13 13:24'
        },
        {
          id: '2',
          imageSrc: 'img/a1.jpg',
          timeByNow: '7小时前',
          doctorName: '谭政',
          occupation: '物理师',
          detailMsg: '邀请你查看患者曹丽华的压模',
          lastTime: '2016-09-13 13:24'
        },
        {
          id: '3',
          imageSrc: 'img/a2.jpg',
          timeByNow: '7小时前',
          doctorName: '王立文',
          occupation: '物理师',
          detailMsg: '邀请你查看患者曹丽华的压模',
          lastTime: '2016-09-13 13:24'
        }
      ]
      $scope.doctorid = localStorage.getItem('chooseDoctorId');
      $log.debug($scope.doctorid);
      if (!_undefined($scope.doctorid)) {
        angular.forEach($scope.initDrs, function (data, index, array) {
          if ($scope.doctorid == data.id && index != '0') {
            var thisData = $scope.initDrs.splice(index, 1);
            $log.debug(thisData);
            $scope.initDrs.splice(0, 0, thisData[0]);
          }
        })
      }

      $log.debug($scope.initDrs);
      $scope.doctors = $scope.initDrs;
      $scope.load = function () {
        $(".users-list>div:first").addClass('chooseColor');
        $('.chat-user').bind('click', function () {
          $(this).addClass('chooseColor').siblings().removeClass('chooseColor');
        });
      }
      $scope.patientName = '曹丽华';
      $scope.patientImg = 'img/a6.jpg';
      $scope.phoneNum = '1856544885';
      $scope.detailMessage='曹丽华压模详情，曹丽华压模详情曹丽华压模详情'
    }

    // $scope.chooseDoctor=function (e) {
    //  $(".chat-user").removeClass('chooseColor');
    //   event.target.class('chooseColor')
    //   $log.debug(event.target);
    // }
    // $('.chat-user').bind('click', function(){
    //   $(this).addClass('chooseColor').siblings().removeClass('chooseColor');
    // });
    $scope.chooseDr = function (id) {
      switch (id) {
        case '1':
          $scope.patientName = '曹丽华';
          $scope.patientImg = 'img/a6.jpg';
          $scope.phoneNum = '1856544885';
          $scope.detailMessage='曹丽华压模详情，曹丽华压模详情曹丽华压模详情'
          break;
        case '2':
          $scope.patientName = '郑方圆';
          $scope.patientImg = 'img/a7.jpg';
          $scope.phoneNum = '1554544885';
          $scope.detailMessage='郑方圆，曹丽华压模详发生在发展生产华压模详情'
          break;
        case '3':
          $scope.patientName = '刘士安';
          $scope.patientImg = 'img/a8.jpg';
          $scope.phoneNum = '1554554523';
          $scope.detailMessage='打算打算模详发生在发展生产华压模详情'
          break;
      }
    }
    //  angular.element(".chat-user").bind('click', function() {
    //    //
    //      $(this).addClass('chooseColor').siblings().removeClass('chooseColor');
    //    // });
    //  })
  })
